package com.hps.notifymsg.pay.controller;

import com.hps.notifymsg.pay.entity.AccountPay;
import com.hps.notifymsg.pay.service.AccountPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author heps
 * @date 2019/12/14 15:44
 */
@RestController
public class AccountPayController {

    @Autowired
    private AccountPayService accountPayService;

    @GetMapping("/paydo")
    public AccountPay pay(AccountPay accountPay) {
        String txNo = UUID.randomUUID().toString();
        accountPay.setId(txNo);
        return accountPayService.insertAccountPay(accountPay);
    }

    @GetMapping("/payresult/{txNo}")
    public AccountPay payResult(@PathVariable("txNo") String txNo) {
        return accountPayService.getAccountPay(txNo);
    }
}
